package com.starbaba.stat.view;

import java.io.InputStream;

import com.base.common.log.LogService;
import com.opensymphony.xwork2.ModelDriven;
import com.starbaba.core.utils.PropertyParamMapBuilder;
import com.starbaba.core.utils.Struts2Utils;
import com.starbaba.core.utils.json.JsonUtils;
import com.starbaba.core.web.page.PageResponse;
import com.starbaba.core.web.struts2.BaseAction;
import com.starbaba.stat.model.ArpuStatVO;
import com.starbaba.stat.service.StatArpuService;
import com.starbaba.stat.service.impl.StatArpuServiceImpl;

/**
 * arpu值统计
 * @author Administrator
 *
 */
@SuppressWarnings({"serial","rawtypes"})
public class StatArpuAction extends BaseAction implements ModelDriven<ArpuStatVO> {

    private ArpuStatVO model;

    private InputStream input;

    private String fileName;

    public StatArpuAction() {
    }
    private StatArpuService service = new StatArpuServiceImpl();

    /**
     * 查询ARPU统计数据
     */
    public void queryARPUStatistics() {
        paramsMap = PropertyParamMapBuilder.buildFromHttpRequest(
                Struts2Utils.getRequest(), paramsMap);
        parsePageRequest();
        try {
            PageResponse pageResponse = service.queryARPUStatistics(paramsMap, pageRequest, true);
            sendJsonMessage(JsonUtils.toJson(pageResponse, null, true, null,
                    false));
        } catch (Exception e) {
            e.printStackTrace();
            LogService.error("getGeneraldata", e);
        }
    }

    public InputStream getInputStream() {
        return input;
    }

    public String getFileName() {
        return fileName;
    }


    @Override
    public ArpuStatVO getModel() {
        if (model == null) {
            model = new ArpuStatVO();
        }
        return model;
    }
}